package com.ymatou.iapi.trading.operate.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.TreeMap;
import java.util.stream.Collectors;

import org.apache.commons.collections.CollectionUtils;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.optrade.service.PrepaidCardService;
import com.ymatou.iapi.trading.operate.parameter.Order;
import com.ymatou.iapi.trading.operate.parameter.OrderItemVo;
import com.ymatou.iapi.trading.operate.parameter.OrderVo;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderService;
import com.ymatou.iapi.trading.operate.parameter.enums.LogisticsTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.PlatformEnum;
import com.ymatou.iapi.trading.operate.parameter.enums.TerminalSourceEnum;
import com.ymatou.iapi.trading.operate.parameter.po.OrderInfoSubPo;
import com.ymatou.iapi.trading.operate.parameter.po.SubcatalogsPo;
import com.ymatou.iapi.trading.operate.parameter.req.OrderPayRequestBean;
import com.ymatou.iapi.trading.operate.parameter.req.PlaceOrderReq;
import com.ymatou.iapi.trading.operate.service.OrderPayRequestCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P2;
import com.ymt.utils.tag.P3;
import com.ymttest.business.data.Sign;
import com.ymttest.business.service.AccountCallServiceV2;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.business.service.PayGateWayCallService;
import com.ymttest.business.service.PaymentProxyCallService;
import com.ymttest.database.model.PPBussinessOrder;
import com.ymttest.database.model.PPPayment;
import com.ymttest.database.model.YmtAccountEntry;
import com.ymttest.database.model.YmtOrderInfo;
import com.ymttest.database.model.YmtOrders;
import com.ymttest.database.mongo.YMatouSellerOrderWapper;
import com.ymttest.database.sqlwapper.AccountDefaultWapper;
import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.database.sqlwapper.PaymentDefaultWapper;
import com.ymttest.database.sqlwapper.YmtOrderInfoWapper;
import com.ymttest.database.sqlwapper.YmtOrdersWapper;
import com.ymttest.database.sqlwapper.YmtProductsIWapper;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.constant.ECode;

/**
 * 新增支付接口 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_OrderPayRequest {
	private static OrderPayRequestBean orderpayrequestbean;

	private static OrderPayRequestCall orderpayrequestcall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("新增支付接口");
	}

	@Before
	public void caseUp() {
		orderpayrequestbean = new OrderPayRequestBean();
		orderpayrequestcall = new OrderPayRequestCall();

	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(orderpayrequestcall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	/**
	 * 
	 * 组合商品订单
	 * 
	 */
	private static PlaceOrderResp placeOrder() {
		PlaceOrderReq placeorderBean = new PlaceOrderReq();
		SubcatalogsPo subcatalogsPo = null, subcatalogsPo2 = null;
		try {

			subcatalogsPo = new YmtProductsIWapper().getSubcatalogs();
			subcatalogsPo2 = new YmtProductsIWapper().getSubcatalogs();

		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		//组合商品
		String catalogId = subcatalogsPo.getCatalogId();

		placeorderBean = PlaceOrderService.getDefaultOrderReq();

		OrderItemVo OrderItemVo = placeorderBean.getOrderGroups().get(0)
				.getOrders().get(0).getOrderItems().get(0);

		OrderItemVo.setCatalogId(catalogId);

		OrderItemVo.setSubProduct(true);

		OrderItemVo.setFreight(new BigDecimal(new Random().nextInt(100)));

		OrderItemVo OrderItemVo2 = PlaceOrderService.getDefaultOrderItemVo();

		OrderItemVo2.setCatalogId(subcatalogsPo2.getCatalogId());

		OrderItemVo2.setFreight(new BigDecimal(new Random().nextInt(100)));

		OrderItemVo2.setSubProduct(true);

		placeorderBean.getOrderGroups().get(0).getOrders().get(0)
				.getOrderItems().add(OrderItemVo2);

		return PlaceOrderService.callPlaceOrderService(placeorderBean);

	}

	/**
	 * 
	 * 贝海保税订单,指定收件人,年使用额度超过20000
	 * 
	 */
	public static PlaceOrderResp placeOrder2(String name,
			LogisticsTypeEnum logisticsType, boolean isEcommerceFlag) {

		PlaceOrderReq placeorderBean = PlaceOrderService.getDefaultOrderReq();

		OrderVo orderVo = placeorderBean.getOrderGroups().get(0).getOrders()
				.get(0);

		orderVo.getOrderItems().get(0).setLogisticsType(logisticsType);

		orderVo.setEcommerceFlag(isEcommerceFlag);

		orderVo.setReceiveName(name);

		return PlaceOrderService.callPlaceOrderService(placeorderBean);

	}

	/**
	 * 验证alipayapp 返回
	 * 
	 * @param orderId
	 * @throws Exception
	 */
	private void verifyAlipayApp(Integer orderId) throws Exception {
		Logger.comment("验证支付宝APP Result报文");

		// 订单主表
		List<Map> ymtOrders = new DefaultWapper().selectOrderByOderId(orderId);
		// 第三方支付的金额=订单应付金额-使用余额支付的金额
		BigDecimal totalFee = new OrderCallService().getNeedPrePayAmountOfCash(
				orderId).subtract(
				orderpayrequestbean.getUseAccountAmount() == null
						? BigDecimal.ZERO
						: orderpayrequestbean.getUseAccountAmount());

		String productName = (String) ymtOrders.get(0).get("sBuyerLoginId")
				+ "的订单";

		Map m = (Map) FormatUtil.GSONToObject(orderpayrequestcall.getData()
				.getString("result"), Map.class);
		Logger.verifyNotNull(m.get("Sign"), "验证Sign非空");
		Logger.verifyEquals(PayGateWayCallService.Alipay_MERID, m.get("Partner"),
				"验证partner合作者身份ID");
		Logger.verifyEquals(PayGateWayCallService.Alipay_EMAIL, m.get("SellerId"),
				"验证SellerId买家支付宝账号");

		PPBussinessOrder ppb = new PaymentDefaultWapper()
				.selectPPBussinessorderByOrderId(
						orderpayrequestcall.getData().getString("tradingId"))
				.get(0);

		String businessoid = ppb.getBussinessOrderId();
		PPPayment ppm = new PaymentDefaultWapper()
				.selectPPPaymentByBussinessOrderId(businessoid).get(0);
		HashMap mext = (HashMap) FormatUtil.GSONToObject(ppb.getExt(),
				HashMap.class);
		int isHangzhou = 0;
		if (mext.size() > 0) {
			isHangzhou = Double.valueOf(mext.get("IsHangZhou").toString())
					.intValue();
		}
		String trandno = ppm.getPaymentId();

		Logger.verifyEquals(trandno, m.get("OutTradeNo"), "验证OutTradeNo");
		Logger.verifyEquals(productName, m.get("Subject"), "验证Subject");

		Logger.comment("totalFee:" + totalFee.toString());
		Logger.verifyEquals(
				true,
				TestDataManager.equalsBigDecimal(
						new BigDecimal(m.get("TotalFee").toString()),
						totalFee.toString()),
				"验证total_fee:" + m.get("TotalFee"));

		if (EnvSetup.getEnv().equals("sit1")) {
			Logger.verifyEquals(
					"http://" + "sit" + ".payment.ymatou.com:8380/notify/"
							+ orderpayrequestbean.getPayType(),
					m.get("NotifyUrl"), "验证NotifyUrl");
		} else if (EnvSetup.getEnv().equals("uat")) {
			Logger.verifyEquals(
					"http://" + "uat" + ".payment.ymatou.com:8480/notify/"
							+ orderpayrequestbean.getPayType(),
					m.get("NotifyUrl"), "验证NotifyUrl");
		}
		Logger.verifyEquals("mobile.securitypay.pay", m.get("Service"),
				"验证Service");
		Logger.verifyEquals("1", m.get("PaymentType"), "验证PaymentType");
		Logger.verifyEquals("utf-8", m.get("InputCharset"), "验证InputCharset");
		Logger.verifyEquals("10d", m.get("ItBPay"), "验证ItBPay");
		Logger.verifyEquals("RSA", m.get("SignType"), "验证SignType");
		Logger.verifyEquals(true, m.get("QuerySuccess"), "验证QuerySuccess");
		Logger.verifyEquals("成功", m.get("Message"), "验证Message");
		Logger.comment("验证EncryptStr");
		Map mencrypt = FormatUtil.httpStringToMap(m.get("EncryptStr")
				.toString());
		Logger.verifyNotNull(mencrypt.get("sign"), "验证Sign非空");
		Logger.verifyEquals(PayGateWayCallService.Alipay_MERID, mencrypt.get("partner"),
				"验证partner合作者身份ID");
		Logger.verifyEquals(PayGateWayCallService.Alipay_EMAIL, mencrypt.get("seller_id"),
				"验证seller_id买家支付宝账号");
		Logger.verifyEquals(trandno, mencrypt.get("out_trade_no"),
				"验证out_trade_no");
		Logger.verifyEquals(productName, mencrypt.get("subject"), "验证subject");
		Logger.verifyEquals(true, TestDataManager.equalsBigDecimal(
				new BigDecimal(mencrypt.get("total_fee").toString()),
				totalFee.toString()),
				"验证total_fee:" + mencrypt.get("total_fee"));
		if (EnvSetup.getEnv().equals("sit1")) {
			Logger.verifyEquals(
					"http://" + "sit" + ".payment.ymatou.com:8380/notify/"
							+ orderpayrequestbean.getPayType(),
					mencrypt.get("notify_url"), "验证notify_url");
		} else if (EnvSetup.getEnv().equals("uat")) {
			Logger.verifyEquals(
					"http://" + "uat" + ".payment.ymatou.com:8480/notify/"
							+ orderpayrequestbean.getPayType(),
					mencrypt.get("notify_url"), "验证notify_url");
		}
		Logger.verifyEquals("mobile.securitypay.pay", mencrypt.get("service"),
				"验证service");
		Logger.verifyEquals("1", mencrypt.get("payment_type"), "验证payment_type");
		Logger.verifyEquals("utf-8", mencrypt.get("_input_charset"),
				"验证_input_charset");
		Logger.verifyEquals("10d", mencrypt.get("it_b_pay"), "验证it_b_pay");
		Logger.verifyEquals("RSA", mencrypt.get("sign_type"), "验证sign_type");
		Logger.verifyEquals("m.alipay.com", mencrypt.get("show_url"),
				"验证show_url");
		// 杭保实名，非杭保不验
		if (isHangzhou == 1) {
			Logger.verifyEquals("T", mencrypt.get("rn_check"), "验证rn_check");
		}
		Logger.verifyNotNull(mencrypt.get("sign"), "验证sign非空");
	}
	/**
	 * 校验Html Form返回 支付宝PC支付
	 * 
	 * @param orderId
	 * @throws Exception
	 */
	private void verifyHtmlResult(Integer orderId) throws Exception {
		Logger.comment("验证支付宝PC Result");
		Map m = new HashMap<String, String>();
		// 订单主表
		List<Map> ymtOrders = new DefaultWapper().selectOrderByOderId(orderId);
		BigDecimal totalFee = ((BigDecimal) ymtOrders.get(0).get("fOrderPrice"))
				.add(((BigDecimal) ymtOrders.get(0).get("fFreight")));
		String productName = (String) ymtOrders.get(0).get("sBuyerLoginId")
				+ "的订单";
		// 返回报文result
		String result = orderpayrequestcall.getData().getString("result");
		List<String> namelist = TestDataManager.getRegexList(result,
				"(?<=name=\").*?(?=\")");
		List<String> valuelist = TestDataManager.getRegexList(result,
				"(?<=value=\").*?(?=\")");
		if (valuelist.size() == namelist.size()) {
			for (int i = 0; i < namelist.size(); i++) {
				m.put(namelist.get(i), valuelist.get(i));
			}
		} else {
			throw new Exception("verifyResult失败，结果集name value 不匹配");
		}
		PPBussinessOrder ppb = new PaymentDefaultWapper()
				.selectPPBussinessorderByOrderId(
						orderpayrequestcall.getData().getString("tradingId"))
				.get(0);

		HashMap mext = (HashMap) FormatUtil.GSONToObject(ppb.getExt(),
				HashMap.class);
		int isHangzhou = Double.valueOf(mext.get("IsHangZhou").toString())
				.intValue();

		String businessoid = ppb.getBussinessOrderId();
		PPPayment ppm = new PaymentDefaultWapper()
				.selectPPPaymentByBussinessOrderId(businessoid).get(0);
		String trandno = ppm.getPaymentId();
		Logger.verifyEquals(productName, m.get("subject"), "验证subject");
		Logger.verifyEquals("RSA", m.get("sign_type"), "验证sign_type");

		if (EnvSetup.getEnv().equals("sit1")) {
			Logger.verifyEquals(
					"http://" + "sit" + ".payment.ymatou.com:8380/notify/"
							+ orderpayrequestbean.getPayType(),
					m.get("notify_url"), "验证notify_url");
			Logger.verifyEquals(trandno, m.get("out_trade_no"),
					"验证out_trade_no");
			Logger.verifyEquals("http://" + "sit"
					+ ".payment.ymatou.com:8380/callback/"
					+ orderpayrequestbean.getPayType(), m.get("return_url"),
					"验证return_url");
		} else if (EnvSetup.getEnv().equals("uat")) {
			Logger.verifyEquals(
					"http://" + "uat" + ".payment.ymatou.com:8480/notify/"
							+ orderpayrequestbean.getPayType(),
					m.get("notify_url"), "验证notify_url");
			Logger.verifyEquals(trandno, m.get("out_trade_no"),
					"验证out_trade_no");
			Logger.verifyEquals("http://" + "uat"
					+ ".payment.ymatou.com:8480/callback/"
					+ orderpayrequestbean.getPayType(), m.get("return_url"),
					"验证return_url");
		}

		// sign算法未知
		Logger.verifyNotNull(m.get("sign"), "验证sign非空");
		Logger.verifyEquals("utf-8", m.get("_input_charset"),
				"验证_input_charset");
		Logger.verifyEquals(orderpayrequestbean.getUserIp(),
				m.get("exter_invoke_ip"), "验证exter_invoke_ip");
		Logger.verifyEquals(
				true,
				TestDataManager.equalsBigDecimal(
						new BigDecimal(m.get("total_fee").toString()),
						totalFee.toString()),
				"验证total_fee:" + m.get("total_fee"));
		if (isHangzhou == 1) {
			Logger.comment("验证杭保信息");
			Logger.verifyEquals(
					"{&quot;needBuyerRealnamed&quot;:&quot;T&quot;}",
					m.get("buyer_info"), "验证buyer_info买家信息");
			Logger.verifyEquals("alipay.acquire.page.createandpay",
					m.get("service"), "验证service统一下单并支付");
			Logger.verifyEquals("FAST_INSTANT_TRADE_PAY",
					m.get("product_code"), "验证product_code订单业务类型");
		} else {
			Logger.comment("验证非杭保信息");
			Logger.verifyEquals(orderpayrequestbean.getBankId(),
					m.get("defaultbank"), "验证defaultbank默认银行");
			Logger.verifyEquals("create_direct_pay_by_user", m.get("service"),
					"验证service统一下单并支付");
			Logger.verifyEquals(ppb.getThirdPartyUserId() == null ? "N" : "Y",
					m.get("default_login"), "验证default_login默认登录");
		}
		// 固定
		Logger.verifyEquals(PayGateWayCallService.Alipay_MERID, m.get("partner"),
				"验证partner合作者身份ID");
		Logger.verifyNotNull(m.get("anti_phishing_key"),
				"验证anti_phishing_key防钓鱼时间戳");
		Logger.verifyEquals(PayGateWayCallService.Alipay_EMAIL, m.get("seller_email"),
				"验证seller_email买家支付宝账号");
		Logger.verifyEquals("1", m.get("payment_type"),
				"验证payment_type 1（商品购买）");
	}

	/**
	 * 校验weixin 微信-JSAPI
	 * 
	 * @param orderId
	 * @throws Exception
	 */
	private void verifyWeixin() {
		try {
			Logger.comment("验证微信JSAPI Result报文");
			HashMap mresult = (HashMap) FormatUtil.GSONToObject(
					orderpayrequestcall.getData().getString("result"),
					HashMap.class);
			Logger.verifyNotNull(mresult.get("AppID"), "验证AppID 公众号");
			Logger.verifyNotNull(mresult.get("TimeStamp"), "验证TimeStamp非空");
			Logger.verifyNotNull(mresult.get("NonceStr"), "验证NonceStr非空");
			Logger.verifyNotNull(mresult.get("Package"), "验证Package非空");
			String sign = null;
			String mysign = null;
			if (orderpayrequestbean.getPayType().equals("15")) {
				Logger.verifyEquals("Sign=WXPay", mresult.get("Package"),
						"验证SignType");
				sign = mresult.get("Sign").toString();
				String merchantId = mresult.get("MerchantId").toString();
				Map resetmap = new TreeMap();
				resetmap.put("appid", mresult.get("AppID"));
				resetmap.put("partnerid", mresult.get("MerchantId"));
				resetmap.put("prepayid", mresult.get("PayToken"));
				resetmap.put("timestamp", mresult.get("TimeStamp"));
				resetmap.put("package", mresult.get("Package"));
				resetmap.put("noncestr", mresult.get("NonceStr"));
				Logger.debug("15 resetmap:" + resetmap);
				mysign = new Sign().signMd5(resetmap, Sign.weixinAppKey);
			} else if (orderpayrequestbean.getPayType().equals("14")) {
				Logger.verifyEquals("MD5", mresult.get("SignType"),
						"验证SignType");
				sign = mresult.get("Sign").toString();
				Map resetmap = new TreeMap();
				resetmap.put("appId", mresult.get("AppID"));
				resetmap.put("timeStamp", mresult.get("TimeStamp"));
				resetmap.put("package", mresult.get("Package"));
				resetmap.put("nonceStr", mresult.get("NonceStr"));
				resetmap.put("signType", mresult.get("SignType"));
				Logger.debug("14 resetmap:" + resetmap);
				mysign = new Sign().signMd5(resetmap, Sign.weixinJSAPIKey);
			}
			Logger.verifyEquals(mysign.toLowerCase(), sign.toLowerCase(),
					"验证Sign");
		} catch (Exception e) {
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_001() {
		Logger.start(true, "通过余额支付订单,成功");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();// 支付金额
			Logger.comment("前置数据准备结束");

			DefaultWapper database = new DefaultWapper();
			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(price);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_APP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Map act = new HashMap();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 2);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);
			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(tradingId, (Integer) database.selectOrder(m)
					.get(0).get("iTradingId"), "验证iTradingId");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");
			Logger.verifyEquals(price.setScale(2), actinfos.get(0).getAmount()
					.divide(new BigDecimal(-1), 2, 4), "验证账户金额");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P2.class)
	@TestCase
	public void Tc_OrderPayRequest_002() {
		Logger.start(false, "支付密码错误,支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 支付前账户金额
			DefaultWapper database = new DefaultWapper();
			HashMap m1 = new HashMap();
			m1.put("UserId", userId);
			BigDecimal price1 = (BigDecimal) database.selectAccountInfo(m1)
					.get(0).get("fAvailAmount");
			BigDecimal price3 = placeOrderResp.getPayAmount();// 支付金额
			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "123a";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_APP
					.getValue());
			orderpayrequestbean
					.setParamExt("{\"paymethod\":A, \"showmode\":B}");
			orderpayrequestbean.setMemo("备注");

			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.FAILED201, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals(
					true,
					orderpayrequestcall.getMsg().contains(
							ECode.FAILED201_MSG_39), "验证Msg"
							+ orderpayrequestcall.getMsg());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_OrderPayRequest_003() {
		Logger.start(false, "输入交易号为空,支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			// 支付前账户金额
			DefaultWapper database = new DefaultWapper();
			HashMap m1 = new HashMap();
			m1.put("UserId", userId);
			BigDecimal price1 = (BigDecimal) database.selectAccountInfo(m1)
					.get(0).get("fAvailAmount");
			BigDecimal price3 = placeOrderResp.getPayAmount();
			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(price1);
			// orderpayrequestbean.setTradingId();
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean
					.setParamExt("{\"paymethod\":A, \"showmode\":B}");
			orderpayrequestbean.setMemo("备注");

			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.ERROR400, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("tradingId:交易号不能为空",
					orderpayrequestcall.getMsg(), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_OrderPayRequest_004() {
		Logger.start(false, "输入来源ip为空,支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 支付前账户金额
			DefaultWapper database = new DefaultWapper();
			HashMap m1 = new HashMap();
			m1.put("UserId", userId);
			BigDecimal price1 = (BigDecimal) database.selectAccountInfo(m1)
					.get(0).get("fAvailAmount");
			BigDecimal price3 = placeOrderResp.getPayAmount();
			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");

			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.ERROR400, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals(
					true,
					orderpayrequestcall.getMsg().contains(ECode.ERROR400_MSG_7),
					"验证Msg" + orderpayrequestcall.getMsg());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_OrderPayRequest_005() {
		Logger.start(false, "输入支付方式为空，支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 支付前账户金额
			DefaultWapper database = new DefaultWapper();
			HashMap m1 = new HashMap();
			m1.put("UserId", userId);
			BigDecimal price1 = (BigDecimal) database.selectAccountInfo(m1)
					.get(0).get("fAvailAmount");
			BigDecimal price3 = placeOrderResp.getPayAmount();
			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean
					.setParamExt("{\"paymethod\":A, \"showmode\":B}");
			orderpayrequestbean.setMemo("备注");

			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.FAILED400, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals(
					true,
					orderpayrequestcall.getMsg().contains(ECode.ERROR400_MSG_8),
					"验证Msg" + orderpayrequestcall.getMsg());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_OrderPayRequest_006() {
		Logger.start(false, "用户可用余额为0,使用账户余额账户");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			Logger.comment("前置数据准备结束");

			// 订单应付金额
			BigDecimal totalPrice = placeOrderResp.getPayAmount();
			// 支付前账户金额
			DefaultWapper database = new DefaultWapper();
			HashMap m1 = new HashMap();
			m1.put("UserId", userId);
			BigDecimal price = (BigDecimal) database.selectAccountInfo(m1)
					.get(0).get("fAvailAmount");
			String accountid = new AccountCallServiceV2().getAccountId(userId);
			// 重置用户账户可以余额为 0
			new AccountCallServiceV2().resetAccount(accountid, new BigDecimal(0),
					new BigDecimal(0));
			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(totalPrice);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd("abc123");
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.FAILED201, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals(ECode.ErrConditionNotMatch,
					orderpayrequestcall.getString("bcode"), "验证BCode");
			Logger.verifyEquals(
					true,
					orderpayrequestcall.getMsg().contains(
							ECode.FAILED201_MSG_69), "验证Msg");
			// 恢复用户余额
			new AccountCallServiceV2().resetAccount(accountid, price,
					new BigDecimal(0));
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_OrderPayRequest_007() {
		Logger.start(false, "用户可用余额小于订单支付金额,使用账户余额账户");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			Logger.comment("前置数据准备结束");

			// 订单应付金额
			BigDecimal totalPrice = placeOrderResp.getPayAmount();

			// 支付前账户金额
			DefaultWapper database = new DefaultWapper();
			HashMap m1 = new HashMap();
			m1.put("UserId", userId);
			BigDecimal price = (BigDecimal) database.selectAccountInfo(m1)
					.get(0).get("fAvailAmount");
			String accountid = new AccountCallServiceV2().getAccountId(userId);
			// 重置用户账户可用余额小于 支付金额
			new AccountCallServiceV2().resetAccount(accountid,
					totalPrice.subtract(new BigDecimal(1)), new BigDecimal(0));
			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(totalPrice);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd("abc123");
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.FAILED201, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals(ECode.ErrConditionNotMatch,
					orderpayrequestcall.getString("bcode"), "验证BCode");
			Logger.verifyEquals(
					true,
					orderpayrequestcall.getMsg().contains(
							ECode.FAILED201_MSG_69), "验证Msg");
			// 恢复用户余额
			new AccountCallServiceV2().resetAccount(accountid, price,
					new BigDecimal(0));
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_OrderPayRequest_008() {
		Logger.start(false, "此交易号不存在，支付失败");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int userId = placeOrderResp.getUserId();

			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(new BigDecimal(10));
			orderpayrequestbean.setTradingId(123456);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");

			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.FAILED201, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals(ECode.BCODE6, orderpayrequestcall.getBCode(),
					"验证Msg" + orderpayrequestcall.getMsg());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	public void Tc_OrderPayRequest_009() {
		Logger.start(false, "当前订单状态不能支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			// 取消订单
			new OrderCallService().cancelOrder(orderId, userId);
			Logger.comment("前置数据准备结束");
			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(new BigDecimal(10));
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.FAILED201, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals(
					true,
					orderpayrequestcall.getMsg().contains(
							ECode.FAILED201_MSG_52), "验证Msg"
							+ orderpayrequestcall.getMsg());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_010() {
		Logger.start(true, "使用支付宝app第三方支付，验证第三方支付接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			// new OrderCallService().orderPayRequest(userId, totalPrice,
			// tradingId);
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("JSON",
					orderpayrequestcall.getData().get("resultType"), "验证Code");
			// 验证支付网关返回报文
			verifyAlipayApp(orderId);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_011() {
		Logger.start(true, "使用支付宝pc第三方支付，验证第三方支付接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("Form",
					orderpayrequestcall.getData().get("resultType"), "验证Code");
			// 验证支付网关返回报文
			verifyHtmlResult(orderId);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_012() {
		Logger.start(true, "使用支付宝wap第三方支付，验证第三方支付接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("11");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			// 验证支付网关返回报文
			Logger.verifyEquals(
					true,
					orderpayrequestcall
							.getData()
							.get("result")
							.toString()
							.contains(
									"http://wappaygw.alipay.com/service/rest.htm"),
					"验证Code");
			Logger.verifyEquals("Query",
					orderpayrequestcall.getData().get("resultType"), "验证Code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_OrderPayRequest_013() {
		Logger.start(true, "使用微信-JSAPI第三方支付，验证第三方支付接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("14");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			// 验证支付网关返回报文
			// Logger.verifyEquals(true,
			// orderpayrequestcall.getData().get("result").toString().contains("http://wappaygw.alipay.com/service/rest.htm"),
			// "验证Code");
			Logger.verifyEquals("JSON",
					orderpayrequestcall.getString("resultType").toString(),
					"验证ResultType");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_014() {
		Logger.start(true, "使用微信app第三方支付，验证第三方支付接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("15");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			// 验证支付网关返回报文
			Logger.verifyEquals("JSON", orderpayrequestcall.getData()
					.getString("resultType").toString(), "验证ResultType");
			verifyWeixin();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_015() {
		Logger.start(true, "使用支付宝app第三方支付,订单物流为杭保,验证第三方支付接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService
					.placeOrderBylogisticsType(LogisticsTypeEnum.XloboBondedDelivery);

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("JSON",
					orderpayrequestcall.getData().get("resultType"), "验证Code");
			// 验证支付网关返回报文
			verifyAlipayApp(orderId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_016() {
		Logger.start(true, "使用账户余额+第三方混合支付,验证第三方支付接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 订单应付金额
			BigDecimal totalPrice = placeOrderResp.getPayAmount();
			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// 使用余额支付一部分
			orderpayrequestbean.setUseAccountAmount(totalPrice
					.subtract(new BigDecimal(11)));
			orderpayrequestbean.setTradingId(tradingId);
			orderpayrequestbean.setTradingPwd("abc123");
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("JSON",
					orderpayrequestcall.getData().get("resultType"), "验证Code");
			// 验证支付网关返回报文
			verifyAlipayApp(orderId);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_017() {
		Logger.start(true, "一笔交易里有多个订单,通过余额支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			List<Order> orders = placeOrderResp.getOrderList();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 获取用户需要支付的金额
			BigDecimal payAmount = new OrderCallService()
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);

			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(payAmount);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			// 用户资金流水记录
			Map act = new HashMap();
			List<YmtAccountEntry> actinfos = new ArrayList<YmtAccountEntry>();
			BigDecimal accountEntryPrice = BigDecimal.ZERO;
			// 数据库校验
			for (int i = 0; i < orders.size(); i++) {
				act.put("bizno", String.valueOf(orders.get(i).getOrderId()));
				act.put("userId", userId);
				actinfos = new AccountDefaultWapper()
						.selectAccountEntryByBizNo(act);
				accountEntryPrice = accountEntryPrice.add(actinfos.get(0)
						.getAmount());
				verifyDb(orders.get(i).getOrderId());
			}
			Logger.verifyEquals(payAmount,
					accountEntryPrice.divide(new BigDecimal(-1), 2, 4),
					"验证账户资金流水金额");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_OrderPayRequest_019() {
		Logger.start(true, "订单支付,校验发送风控校验");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			List<Order> orders = placeOrderResp.getOrderList();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 获取用户需要支付的金额
			// ymt_tradinginfo 表
			List<Map> ymtTradinginfo = new DefaultWapper()
					.selectTradinginfoByTradingId(tradingId);
			BigDecimal payAmount = (BigDecimal) ymtTradinginfo.get(0).get(
					"fPayableAmount");

			// 支付前账户金额
			DefaultWapper database = new DefaultWapper();
			HashMap m1 = new HashMap();
			m1.put("UserId", userId);
			BigDecimal price1 = (BigDecimal) database.selectAccountInfo(m1)
					.get(0).get("fAvailAmount");
			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(payAmount);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");

			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			// 支付后金额
			BigDecimal price2 = (BigDecimal) database.selectAccountInfo(m1)
					.get(0).get("fAvailAmount");
			Logger.verifyEquals(payAmount, price1.subtract(price2), "验证账户金额");
			// 数据库校验
			// 检查点
			YMatouSellerOrderWapper sellerorderwapper = new YMatouSellerOrderWapper();
			Map result = null;
			int count = 0;
			int orderId1 = orders.get(0).getOrderId();
			// 重试3次
			while (result == null && count < 30) {
				Thread.sleep(1000);
				result = sellerorderwapper.selectOrderInfoById(orderId1,
						sellerId);
				count++;
			}
			Logger.comment("Mongo中查询出的订单信息:" + result.toString());
			Logger.verifyEquals(orderId1, (Integer) result.get("_id"),
					"验证OrderId");
			Logger.verifyEquals(sellerId, (Integer) result.get("Seller"),
					"验证Seller");
			Logger.verifyEquals(userId, (Integer) result.get("Buyer"),
					"验证Buyer");
			Logger.verifyEquals(2, (Integer) result.get("TradingStatus"),
					"验证TradingStatus");
			Logger.verifyEquals(1, (Integer) result.get("Type"), "验证Type");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_020() {
		Logger.start(true, "使用账户余额+第三方混合支付,第三方支付回调前,重复用余额支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder4();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 订单应付金额
			BigDecimal totalPrice = placeOrderResp.getPayAmount();
			// 全款第三方支付
			// 13 为 app国际支付宝，15 微信
			String payType = "13";
			BigDecimal blanceAmout = new BigDecimal(11);
			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// 使用余额支付一部分
			orderpayrequestbean.setUseAccountAmount(blanceAmout);
			orderpayrequestbean.setTradingId(tradingId);
			orderpayrequestbean.setTradingPwd("abc123");
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("JSON",
					orderpayrequestcall.getData().get("resultType"), "验证Code");

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");

			DefaultWapper database = new DefaultWapper();

			// 重复用余额支付
			new OrderCallService().orderPayRequest(userId, totalPrice,
					tradingId, payType);
			Map act = new HashMap();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 2);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);
			Logger.comment("第三方支付回调前,用余额重复支付");
			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");
			Logger.verifyEquals(totalPrice.setScale(2), actinfos.get(0)
					.getAmount().divide(new BigDecimal(-1), 2, 4),
					"验证账户资金订单支付流水金额");
			// 支付网关支付回调交易
			Logger.comment("第三方支付回调");
			PaymentProxyCallService.notifyCall(payType, thirdTradingId,
					totalPrice.subtract(blanceAmout).toString(), userId);

			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			Logger.verifyEquals(1, actinfos.size(), "验证只扣款一次");
			act.remove("bizno");
			act.put("originalNo", String.valueOf(thirdTradingId));

			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			Logger.verifyEquals(totalPrice.subtract(blanceAmout).setScale(2),
					actinfos.get(0).getAmount(), "验证账户资金定金充值流水金额");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_021() {
		Logger.start(true, "使用账户余额+第三方混合支付,第三方支付回调前,重复第三方支付,网关成功回调第二笔第三方支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder4();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 订单应付金额
			BigDecimal totalPrice = placeOrderResp.getPayAmount();
			// 13 为 app国际支付宝，15 微信
			String payType = "13";
			BigDecimal blanceAmout = new BigDecimal(11);
			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// 使用余额支付一部分
			orderpayrequestbean.setUseAccountAmount(blanceAmout);
			orderpayrequestbean.setTradingId(tradingId);
			orderpayrequestbean.setTradingPwd("abc123");
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("JSON",
					orderpayrequestcall.getData().get("resultType"), "验证Code");

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");

			DefaultWapper database = new DefaultWapper();

			// 第二次支付用的余额
			BigDecimal blanceAmout2 = new BigDecimal(26);
			Logger.comment("第三方支付回调前,用第三方重复支付");

			// 重复支付
			int thirdTradingId2 = new OrderCallService().orderPayRequest(
					userId, blanceAmout2, tradingId, payType);
			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall(payType,
					String.valueOf(thirdTradingId2),
					totalPrice.subtract(blanceAmout2).toString(), userId);
			Thread.sleep(5000);
			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 2);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);
			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");
			Map act = new HashMap();
			List<YmtAccountEntry> actinfos = new ArrayList<YmtAccountEntry>();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			Logger.verifyEquals(totalPrice.setScale(2), actinfos.get(0)
					.getAmount().divide(new BigDecimal(-1), 2, 4),
					"验证账户资金流水用户支付金额");
			act.remove("bizno");
			act.put("originalNo", String.valueOf(thirdTradingId2));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			Logger.verifyEquals(totalPrice.subtract(blanceAmout2).setScale(2),
					actinfos.get(0).getAmount(), "验证账户资金流水第三方支付充值金额");
			Logger.comment("支付网关重复回调交易");
			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall(payType, thirdTradingId,
					totalPrice.subtract(blanceAmout).toString(), userId);
			Thread.sleep(5000);

			act.put("originalNo", String.valueOf(thirdTradingId));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			Logger.verifyEquals(totalPrice.subtract(blanceAmout).setScale(2),
					actinfos.get(0).getAmount(), "验证支付网关重复回调后账户资金流水定金充值金额");
			act.remove("originalNo");
			act.put("bizno", String.valueOf(orderId));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			Logger.verifyEquals(1, actinfos.size(),
					"验证支付网关重复回调后账户资金流水只有一次订单支付记录");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_022() {
		Logger.start(true, "使用账户余额+第三方混合支付,第三方支付回调前,重复第三方支付,网关成功回调第一笔第三方支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 订单应付金额
			BigDecimal totalPrice = placeOrderResp.getPayAmount();
			// 13 为 app国际支付宝，15 微信
			String payType = "13";
			BigDecimal blanceAmout = new BigDecimal(11);
			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// 使用余额支付一部分
			orderpayrequestbean.setUseAccountAmount(blanceAmout);
			orderpayrequestbean.setTradingId(tradingId);
			orderpayrequestbean.setTradingPwd("abc123");
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("JSON",
					orderpayrequestcall.getData().get("resultType"), "验证Code");

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");

			DefaultWapper database = new DefaultWapper();

			// 第二次支付用的余额
			BigDecimal blanceAmout2 = new BigDecimal(26);
			// 重复支付
			int thirdTradingId2 = new OrderCallService().orderPayRequest(
					userId, blanceAmout2, tradingId, payType);
			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall(payType,
					String.valueOf(thirdTradingId),
					totalPrice.subtract(blanceAmout).toString(), userId);
			Thread.sleep(5000);
			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 2);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);
			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");
			Map act = new HashMap();
			List<YmtAccountEntry> actinfos = new ArrayList<YmtAccountEntry>();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			Logger.verifyEquals(totalPrice.setScale(2), actinfos.get(0)
					.getAmount().divide(new BigDecimal(-1), 2, 4),
					"验证账户资金流水用户支付金额");
			act.remove("bizno");
			act.put("originalNo", String.valueOf(thirdTradingId));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			Logger.verifyEquals(totalPrice.subtract(blanceAmout).setScale(2),
					actinfos.get(0).getAmount(), "验证账户资金流水第三方支付充值金额");

			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall(payType,
					String.valueOf(thirdTradingId2),
					totalPrice.subtract(blanceAmout2).toString(), userId);
			Thread.sleep(5000);
			act.put("originalNo", String.valueOf(thirdTradingId2));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			Logger.verifyEquals(totalPrice.subtract(blanceAmout2).setScale(2),
					actinfos.get(0).getAmount(), "验证支付网关重复回调后账户资金流水定金充值金额");
			act.remove("originalNo");
			act.put("bizno", String.valueOf(orderId));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			Logger.verifyEquals(1, actinfos.size(),
					"验证支付网关重复回调后账户资金流水只有一次订单支付记录");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_023() {
		Logger.start(true, "杭保物流下单，使用支付宝app第三方支付，验证第三方支付接口返回报文");
		try {
			// 创建订单
			PlaceOrderResp placeOrderResp = PlaceOrderService
					.placeOrderBylogisticsType(LogisticsTypeEnum.XloboBondedDelivery);

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("JSON",
					orderpayrequestcall.getData().get("resultType"), "验证Code");
			// 验证支付网关返回报文
			verifyAlipayApp(orderId);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_024() {
		Logger.start(true, "单个订单,一个商品，使用招行支付,支付网关回调成功");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayAmount();
			BigDecimal blanceAmout = BigDecimal.ZERO;
			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(blanceAmout);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("50");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");
			// 支付网关支付回调交易
			String cmbDiscountAmount = PaymentProxyCallService.cmbNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(blanceAmout).toString(), userId);

			Thread.sleep(3000);
			// 支付后金额
			Map act = new HashMap();
			act.put("userId", userId);
			// 定金充值流水
			act.put("originalNo", String.valueOf(thirdTradingId));

			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			BigDecimal accountEntryPrice = actinfos.stream()
					.map(a -> a.getAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			// 支付网关充值流水
			Logger.verifyEquals(totalPrice.subtract(blanceAmout).setScale(2),
					accountEntryPrice, "验证账户资金订单充值流水金额");

			// 定金支付流水
			act.put("originalNo", String.valueOf(tradingId));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			accountEntryPrice = actinfos.stream().map(a -> a.getAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);
			// 定金支付流水
			Logger.verifyEquals(totalPrice.subtract(blanceAmout).setScale(2),
					accountEntryPrice.divide(new BigDecimal(-1), 2, 4),
					"验证账户资金订单支付流水金额");

			Logger.debug("cmbDiscountAmount:" + cmbDiscountAmount);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("Form",
					orderpayrequestcall.getData().get("resultType"), "验证Code");
			// 验证支付网关返回报文
			verifyCMBHtmlResult(orderId, totalPrice);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_025() {
		Logger.start(true, "单个订单,一个商品，使用招行支付,支付网关回调之前,订单已经取消，走快速退款");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			BigDecimal totalPrice = placeOrderResp.getPayAmount();
			BigDecimal blanceAmout = BigDecimal.ZERO;
			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(blanceAmout);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("50");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");
			// 订单取消
			new OrderCallService().cancelOrder(orderId, userId);
			// 支付网关支付回调交易
			String cmbDiscountAmount = PaymentProxyCallService.cmbNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(blanceAmout).toString(), userId);
			Thread.sleep(5000);

			/*
			 * // 退款回调
			 * PaymentProxyCallService.refundNotifyCall(orderpayrequestbean
			 * .getPayType(), String.valueOf(thirdTradingId), totalPrice
			 * .subtract(blanceAmout) .toString(), userId);
			 */
			// Thread.sleep(5000);

			Logger.debug("cmbDiscountAmount:" + cmbDiscountAmount);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("Form",
					orderpayrequestcall.getData().get("resultType"), "验证Code");
			// 验证支付网关返回报文
			verifyCMBHtmlResult(orderId, totalPrice);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_026() {
		Logger.start(true, "一个订单多个商品,全额使用招行支付,支付网关回调成功,校验招行平台补贴金额分摊");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			List<Order> orders = placeOrderResp.getOrderList();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal totalNeedPayAmout = placeOrderResp.getPayAmount();// 支付金额

			Logger.comment("前置数据准备结束");

			// 获取用户需要支付的金额
			BigDecimal totalPrice = new OrderCallService()
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			BigDecimal blanceAmout = BigDecimal.ZERO;
			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(blanceAmout);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("50");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");
			// 支付网关支付回调交易
			String cmbDiscountAmount = PaymentProxyCallService.cmbNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(blanceAmout).toString(), userId);

			Thread.sleep(5000);
			// 支付后金额
			Map act = new HashMap();
			act.put("userId", userId);
			// 定金充值流水
			act.put("originalNo", String.valueOf(thirdTradingId));

			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			BigDecimal accountEntryPrice = actinfos.stream()
					.map(a -> a.getAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			// 支付网关充值流水
			Logger.verifyEquals(totalPrice.subtract(blanceAmout).setScale(2),
					accountEntryPrice, "验证账户资金订单充值流水金额");

			// 定金支付流水
			act.put("originalNo", String.valueOf(tradingId));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			accountEntryPrice = actinfos.stream().map(a -> a.getAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);
			// 定金支付流水
			Logger.verifyEquals(totalPrice.setScale(2),
					accountEntryPrice.divide(new BigDecimal(-1), 2, 4),
					"验证账户资金订单支付流水金额");

			Logger.debug("cmbDiscountAmount:" + cmbDiscountAmount);

			List<YmtOrders> orderList = new YmtOrdersWapper()
					.selectbyMainOrder(tradingId);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("Form",
					orderpayrequestcall.getData().get("resultType"), "验证Code");
			// 验证支付网关返回报文
			verifyCmb(Integer.valueOf(thirdTradingId), orderList, totalPrice,
					totalPrice.subtract(blanceAmout), new BigDecimal(
							cmbDiscountAmount));
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_027() {
		Logger.start(true, "一个订单多个商品,使用招行+用户余额,支付网关回调成功,校验招行平台补贴金额分摊");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			List<Order> orders = placeOrderResp.getOrderList();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal totalNeedPayAmout = placeOrderResp.getPayAmount();// 支付金额

			Logger.comment("前置数据准备结束");

			// 获取用户需要支付的金额
			BigDecimal totalPrice = new OrderCallService()
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			BigDecimal blanceAmout = new BigDecimal(
					new Random().nextInt(100) + 1);
			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(blanceAmout);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("50");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");
			// 支付网关支付回调交易
			String cmbDiscountAmount = PaymentProxyCallService.cmbNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(blanceAmout).toString(), userId);

			Thread.sleep(3000);
			// 支付后金额
			Map act = new HashMap();
			act.put("userId", userId);
			// 定金充值流水
			act.put("originalNo", String.valueOf(thirdTradingId));

			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			BigDecimal accountEntryPrice = actinfos.stream()
					.map(a -> a.getAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			// 支付网关充值流水
			Logger.verifyEquals(totalPrice.subtract(blanceAmout).setScale(2),
					accountEntryPrice, "验证账户资金订单充值流水金额");

			// 定金支付流水
			act.put("originalNo", String.valueOf(tradingId));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			accountEntryPrice = actinfos.stream().map(a -> a.getAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			// 定金支付流水
			Logger.verifyEquals(totalPrice.setScale(2),
					accountEntryPrice.divide(new BigDecimal(-1), 2, 4),
					"验证账户资金订单支付流水金额");

			Logger.debug("cmbDiscountAmount:" + cmbDiscountAmount);

			List<YmtOrders> orderList = new YmtOrdersWapper()
					.selectbyMainOrder(tradingId);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("Form",
					orderpayrequestcall.getData().get("resultType"), "验证Code");
			// 验证支付网关返回报文
			verifyCmb(Integer.valueOf(thirdTradingId), orderList, totalPrice,
					totalPrice.subtract(blanceAmout), new BigDecimal(
							cmbDiscountAmount));

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_028() {
		Logger.start(true,
				"一个订单多个商品,使用招行+用户余额,所有子订单自动取消，支付网关回调，走快速退款，原路退回到第三方账户");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			List<Order> orders = placeOrderResp.getOrderList();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal totalNeedPayAmout = placeOrderResp.getPayAmount();// 支付金额

			Logger.comment("前置数据准备结束");

			// 获取用户需要支付的金额
			BigDecimal totalPrice = new OrderCallService()
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			BigDecimal blanceAmout = new BigDecimal(
					new Random().nextInt(100) + 1);
			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(blanceAmout);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("50");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			// 取消改笔交易下所有订单
			for (int i = 0; i < orders.size(); i++) {
				new OrderCallService().cancelOrder(orders.get(i).getOrderId(),
						userId);
			}

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");
			// 支付网关支付回调交易
			String cmbDiscountAmount = PaymentProxyCallService.cmbNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(blanceAmout).toString(), userId);

			Thread.sleep(5000);

			Logger.debug("cmbDiscountAmount :" + cmbDiscountAmount);
			// 支付后金额
			Map act = new HashMap();
			act.put("userId", userId);
			// 定金充值流水
			act.put("originalNo", String.valueOf(thirdTradingId));

			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			BigDecimal accountEntryPrice = actinfos.stream()
					.map(a -> a.getAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			// 支付网关充值流水
			Logger.verifyEquals(BigDecimal.ZERO.setScale(2), accountEntryPrice,
					"验证账户资金充值金额跟退款金额一致");

			Logger.debug("cmbDiscountAmount:" + cmbDiscountAmount);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("Form",
					orderpayrequestcall.getData().get("resultType"), "验证Code");

			// 验证db数据
			DefaultWapper database = new DefaultWapper();
			for (int i = 0; i < orders.size(); i++) {
				int orderId = orders.get(i).getOrderId();
				// ymt_orderpay 表
				List<Map> ymtOrderPay = database.selectOrderPay(orderId);;
				// 订单表
				List<Map> ymtOrders = database.selectOrderByOderId(orderId);
				// 订单资金表
				List<Map> ymtOrderStateList = database
						.selectOrderStateByOderId(orderId);
				// 当前子订单需要支付的金额
				BigDecimal orderNeedPayAmout = new OrderCallService()
						.getNeedPrePayAmountOfCash(orderId);
				Logger.comment("验证Ymt_Orders表");
				Logger.verifyEquals(null,
						(Integer) ymtOrders.get(0).get("iTradingId"),
						"验证iTradingId");
				Logger.verifyEquals(12,
						(Integer) ymtOrders.get(0).get("iTradingStatus"),
						"验证iTradingStatus");
				Logger.comment("验证ymt_orderstate表");
				Logger.verifyEquals(
						BigDecimal.ZERO.setScale(2),
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fPaidAmountOfCash"), "验证fPaidAmountOfCash");
				Logger.verifyEquals(null, (BigDecimal) ymtOrderStateList.get(0)
						.get("fPaidAmountOfThirdParty"),
						"验证fPaidAmountOfThirdParty");
				Logger.verifyEquals(null, (BigDecimal) ymtOrderStateList.get(0)
						.get("fPaidAmountOfYmtAccount"),
						"验证fPaidAmountOfYmtAccount");
				Logger.verifyEquals(
						BigDecimal.ZERO.setScale(2),
						(BigDecimal) ymtOrderStateList.get(0).get(
								"fRefundedAmountOfCash"),
						"验证fRefundedAmountOfCash");
				Logger.verifyEquals(null, (BigDecimal) ymtOrderStateList.get(0)
						.get("fRefundedPaidAmountToThirdParty"),
						"验证fRefundedPaidAmountToThirdParty");
				Logger.verifyEquals(null,
						ymtOrderStateList.get(0).get("fDiscountOfThirdParty"),
						"验证fDiscountOfThirdParty");
				Logger.comment("验证ymt_orderpay表");
				Logger.verifyEquals(tradingId, (Integer) ymtOrderPay.get(0)
						.get("iTradingId"), "验证iTradingId");
				Logger.verifyEquals(2,
						(Integer) ymtOrderPay.get(0).get("iPayType"),
						"验证iPayType");
				Logger.verifyEquals(orderNeedPayAmout, (BigDecimal) ymtOrderPay
						.get(0).get("fAmount"), "验证fAmount");
				Logger.verifyEquals(-1,
						(Integer) ymtOrderPay.get(0).get("iStatus"),
						"验证iStatus");
				Logger.verifyEquals(null,
						(String) ymtOrderPay.get(0).get("sMemo"), "验证sMemo");
				Logger.verifyEquals(0,
						(Integer) ymtOrderPay.get(0).get("iAccountingNum"),
						"验证iAccountingNum");
				Logger.verifyEquals(null,
						(String) ymtOrderPay.get(0).get("sAccountingMessage"),
						"验证sAccountingMessage");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_029() {
		Logger.start(true, "一个订单多个商品,使用招行+用户余额,子订单部分取消，支付网关回调，走快速退款，原路退回到第三方账户");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder3();

			List<Order> orders = placeOrderResp.getOrderList();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal totalNeedPayAmout = placeOrderResp.getPayAmount();// 支付金额

			Logger.comment("前置数据准备结束");

			// 获取用户需要支付的金额
			BigDecimal totalPrice = new OrderCallService()
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);
			BigDecimal blanceAmout = new BigDecimal(
					new Random().nextInt(100) + 1);
			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(blanceAmout);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("50");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			// 取消改笔交易下其中一个子订单
			new OrderCallService().cancelOrder(orders.get(0).getOrderId(),
					userId);

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");
			// 支付网关支付回调交易
			String cmbDiscountAmount = PaymentProxyCallService.cmbNotifyCall(
					String.valueOf(thirdTradingId),
					totalPrice.subtract(blanceAmout).toString(), userId);

			Thread.sleep(5000);

			Logger.debug("cmbDiscountAmount :" + cmbDiscountAmount);
			// 支付后金额
			Map act = new HashMap();
			act.put("userId", userId);
			// 定金充值流水
			act.put("originalNo", String.valueOf(thirdTradingId));

			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			BigDecimal accountEntryPrice = actinfos.stream()
					.map(a -> a.getAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			// 支付网关充值流水
			Logger.verifyEquals(totalPrice.subtract(blanceAmout).setScale(2),
					accountEntryPrice, "验证账户资金订单充值流水金额");

			// 定金支付流水
			act.put("originalNo", String.valueOf(tradingId));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			accountEntryPrice = actinfos.stream().map(a -> a.getAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			Logger.debug("cmbDiscountAmount:" + cmbDiscountAmount);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("Form",
					orderpayrequestcall.getData().get("resultType"), "验证Code");

			// 验证db数据
			DefaultWapper database = new DefaultWapper();

			int orderId = orders.get(0).getOrderId();
			// ymt_orderpay 表
			List<Map> ymtOrderPay = database.selectOrderPay(orderId);;
			// 订单表
			List<Map> ymtOrders = database.selectOrderByOderId(orderId);
			// 订单资金表
			List<Map> ymtOrderStateList = database
					.selectOrderStateByOderId(orderId);
			// 当前子订单需要支付的金额
			BigDecimal orderNeedPayAmout = new OrderCallService()
					.getNeedPrePayAmountOfCash(orderId);

			// 定金支付流水
			Logger.verifyEquals(totalPrice.subtract(orderNeedPayAmout)
					.setScale(2), accountEntryPrice.divide(new BigDecimal(-1),
					2, 4), "验证账户资金订单支付流水金额");

			Logger.comment("订单号：" + orderId);
			Logger.comment("验证Ymt_Orders表");
			Logger.verifyEquals(null,
					(Integer) ymtOrders.get(0).get("iTradingId"),
					"验证iTradingId");
			Logger.verifyEquals(12,
					(Integer) ymtOrders.get(0).get("iTradingStatus"),
					"验证iTradingStatus");
			Logger.comment("验证ymt_orderstate表");
			Logger.verifyEquals(
					BigDecimal.ZERO.setScale(2),
					(BigDecimal) ymtOrderStateList.get(0).get(
							"fPaidAmountOfCash"), "验证fPaidAmountOfCash");
			Logger.verifyEquals(null, (BigDecimal) ymtOrderStateList.get(0)
					.get("fPaidAmountOfThirdParty"),
					"验证fPaidAmountOfThirdParty");
			Logger.verifyEquals(null, (BigDecimal) ymtOrderStateList.get(0)
					.get("fPaidAmountOfYmtAccount"),
					"验证fPaidAmountOfYmtAccount");
			Logger.verifyEquals(
					BigDecimal.ZERO.setScale(2),
					(BigDecimal) ymtOrderStateList.get(0).get(
							"fRefundedAmountOfCash"), "验证fRefundedAmountOfCash");
			Logger.verifyEquals(null, (BigDecimal) ymtOrderStateList.get(0)
					.get("fRefundedPaidAmountToThirdParty"),
					"验证fRefundedPaidAmountToThirdParty");
			Logger.verifyEquals(null,
					ymtOrderStateList.get(0).get("fDiscountOfThirdParty"),
					"验证fDiscountOfThirdParty");
			Logger.comment("验证ymt_orderpay表");
			Logger.verifyEquals(tradingId,
					(Integer) ymtOrderPay.get(0).get("iTradingId"),
					"验证iTradingId");
			Logger.verifyEquals(2,
					(Integer) ymtOrderPay.get(0).get("iPayType"), "验证iPayType");
			Logger.verifyEquals(orderNeedPayAmout, (BigDecimal) ymtOrderPay
					.get(0).get("fAmount"), "验证fAmount");
			Logger.verifyEquals(-1,
					(Integer) ymtOrderPay.get(0).get("iStatus"), "验证iStatus");
			Logger.verifyEquals(null, (String) ymtOrderPay.get(0).get("sMemo"),
					"验证sMemo");
			Logger.verifyEquals(0,
					(Integer) ymtOrderPay.get(0).get("iAccountingNum"),
					"验证iAccountingNum");
			Logger.verifyEquals(null,
					(String) ymtOrderPay.get(0).get("sAccountingMessage"),
					"验证sAccountingMessage");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_030() {
		Logger.start(true, "第三方支付回调前,重复第三方支付,网关成功回调第二笔第三方支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			Logger.comment("前置数据准备结束");

			// 订单应付金额
			BigDecimal totalPrice = placeOrderResp.getPayAmount();

			// 13 为 app国际支付宝，15 微信
			String payType = "15";
			BigDecimal blanceAmout = BigDecimal.ZERO;
			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// 使用余额支付一部分
			orderpayrequestbean.setUseAccountAmount(blanceAmout);
			orderpayrequestbean.setTradingId(tradingId);
			orderpayrequestbean.setTradingPwd("abc123");
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("JSON",
					orderpayrequestcall.getData().get("resultType"), "验证Code");

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");

			DefaultWapper database = new DefaultWapper();

			// 第二次支付用的余额
			BigDecimal blanceAmout2 = BigDecimal.ZERO;

			Logger.comment("第三方支付回调前,用第三方重复支付");

			// 重复支付
			int thirdTradingId2 = new OrderCallService().orderPayRequest(
					userId, BigDecimal.ZERO, tradingId, payType);

			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall(payType,
					String.valueOf(thirdTradingId2), totalPrice.toString(),
					userId);

			Thread.sleep(3000);

			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall("13",
					String.valueOf(thirdTradingId), totalPrice.toString(),
					userId);

			Thread.sleep(3000);

			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 2);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);
			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");
			Map act = new HashMap();
			List<YmtAccountEntry> actinfos = new ArrayList<YmtAccountEntry>();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			Logger.verifyEquals(totalPrice.setScale(2), actinfos.get(0)
					.getAmount().divide(new BigDecimal(-1), 2, 4),
					"验证账户资金流水用户支付金额");
			act.remove("bizno");
			act.put("originalNo", String.valueOf(thirdTradingId2));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			Logger.verifyEquals(totalPrice.subtract(blanceAmout2).setScale(2),
					actinfos.get(0).getAmount(), "验证账户资金流水第三方支付充值金额");
			Logger.comment("支付网关重复回调交易");
			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall(payType, thirdTradingId,
					totalPrice.subtract(blanceAmout).toString(), userId);
			Thread.sleep(5000);

			act.put("originalNo", String.valueOf(thirdTradingId));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			Logger.verifyEquals(totalPrice.subtract(blanceAmout).setScale(2),
					actinfos.get(0).getAmount(), "验证支付网关重复回调后账户资金流水定金充值金额");
			act.remove("originalNo");
			act.put("bizno", String.valueOf(orderId));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			Logger.verifyEquals(1, actinfos.size(),
					"验证支付网关重复回调后账户资金流水只有一次订单支付记录");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_031() {
		Logger.start(true, "订单收件人,年消费额度超过20000,贝海保税商品支付后，直接取消订单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			String name = "李四";

			PlaceOrderResp placeOrderResp = placeOrder2(name,
					LogisticsTypeEnum.XloboBondedDelivery, false);

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();// 支付金额
			Logger.comment("前置数据准备结束");

			DefaultWapper database = new DefaultWapper();
			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(price);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_APP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");

			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			Thread.sleep(1000);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Map act = new HashMap();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 18);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);
			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(tradingId, (Integer) database.selectOrder(m)
					.get(0).get("iTradingId"), "验证iTradingId");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");
			Logger.verifyEquals(price.setScale(2), actinfos.get(0).getAmount()
					.divide(new BigDecimal(-1), 2, 4), "验证账户金额");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_032() {
		Logger.start(true, "订单收件人,年消费额度不超过20000,贝海保税商品正常支付，不会取消订单");
		try {

			DefaultWapper database = new DefaultWapper();
			// 创建订单
			Logger.comment("前置数据准备");
			String name = "李四";

			PlaceOrderResp placeOrderResp = placeOrder2(name,
					LogisticsTypeEnum.XloboBondedDelivery, false);

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();// 支付金额

			BigDecimal amount = new BigDecimal(20000).subtract(price).subtract(
					new BigDecimal(100));

			List<Map> list = database.executeSql(String.format(
					"select * from Ymt_OrderIdCardCostInfo where name='%s'",
					name));

			if (!CollectionUtils.isEmpty(list)) {
				database.executeUpdateSql(String
						.format("update Ymt_OrderIdCardCostInfo set amount='%s' where name='%s'",
								amount, name));
			}

			else {
				database.executeSql(String
						.format("insert into Ymt_OrderIdCardCostInfo values('370829198706012932','2017','%s',%s,getdate(),getdate())",
								name, amount));

			}

			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(price);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_APP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Map act = new HashMap();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 2);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);
			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(tradingId, (Integer) database.selectOrder(m)
					.get(0).get("iTradingId"), "验证iTradingId");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");
			Logger.verifyEquals(price.setScale(2), actinfos.get(0).getAmount()
					.divide(new BigDecimal(-1), 2, 4), "验证账户金额");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_033() {
		Logger.start(true, "订单收件人,年消费额度超过20000,非贝海保税商品正常支付，不会取消订单");
		try {

			DefaultWapper database = new DefaultWapper();
			// 创建订单
			Logger.comment("前置数据准备");
			String name = "李四";

			PlaceOrderResp placeOrderResp = placeOrder2(name,
					LogisticsTypeEnum.SailProtect, false);

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();// 支付金额

			BigDecimal amount = new BigDecimal(20000);

			List<Map> list = database.executeSql(String.format(
					"select * from Ymt_OrderIdCardCostInfo where name='%s'",
					name));

			if (!CollectionUtils.isEmpty(list)) {
				database.executeUpdateSql(String
						.format("update Ymt_OrderIdCardCostInfo set amount='%s' where name='%s'",
								amount, name));
			}

			else {
				database.executeSql(String
						.format("insert into Ymt_OrderIdCardCostInfo values('370829198706012932','2017','%s',%s,getdate(),getdate())",
								name, amount));

			}

			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(price);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_APP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Map act = new HashMap();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 2);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);
			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(tradingId, (Integer) database.selectOrder(m)
					.get(0).get("iTradingId"), "验证iTradingId");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");
			Logger.verifyEquals(price.setScale(2), actinfos.get(0).getAmount()
					.divide(new BigDecimal(-1), 2, 4), "验证账户金额");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_034() {
		Logger.start(true, "通过余额支付,userid为null订单,成功");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();// 支付金额
			Logger.comment("前置数据准备结束");

			DefaultWapper database = new DefaultWapper();
			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(0);
			orderpayrequestbean.setUseAccountAmount(price);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_APP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Map act = new HashMap();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 2);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);
			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(tradingId, (Integer) database.selectOrder(m)
					.get(0).get("iTradingId"), "验证iTradingId");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");
			Logger.verifyEquals(price.setScale(2), actinfos.get(0).getAmount()
					.divide(new BigDecimal(-1), 2, 4), "验证账户金额");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_035() {
		Logger.start(true, "使用支付宝app第三方支付,userid为0，验证第三方支付接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = new OrderCallService()
					.createM2cOrder();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			;
			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(0);
			// orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			// 支付网关支付回调交易
			PaymentProxyCallService.notifyCall(
					orderpayrequestbean.getPayType(), String
							.valueOf(orderpayrequestcall.getData().get(
									"tradingId")), placeOrderResp
							.getPayAmount().toString(), userId);
			// 等待支付网关异步处理
			Thread.sleep(5000);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("JSON",
					orderpayrequestcall.getData().get("resultType"), "验证Code");
			// 验证支付网关返回报文
			verifyAlipayApp(orderId);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_036() {
		Logger.start(true, "带运费的订单，通过余额支付订单,成功");
		try {
			// 创建订单
			Logger.comment("前置数据准备");
			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder7();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();// 支付金额

			Logger.comment("前置数据准备结束");

			DefaultWapper database = new DefaultWapper();
			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(price);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_APP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Map act = new HashMap();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 2);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);

			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(tradingId, (Integer) database.selectOrder(m)
					.get(0).get("iTradingId"), "验证iTradingId");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_037() {
		Logger.start(true, "含有组合商品的订单,全额使用招行支付,支付网关回调成功,校验招行平台补贴金额分摊");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = placeOrder();

			List<Order> orders = placeOrderResp.getOrderList();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal totalNeedPayAmout = placeOrderResp.getPayAmount();// 支付金额

			Logger.comment("前置数据准备结束");

			// 获取用户需要支付的金额
			BigDecimal totalPrice = new OrderCallService()
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);

			BigDecimal blanceAmout = BigDecimal.ZERO;

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(blanceAmout);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("50");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");
			// 支付网关支付回调交易
			String cmbDiscountAmount = "8";

			PayGateWayCallService.cmbNotifyCall(String.valueOf(thirdTradingId),
					totalPrice.subtract(blanceAmout).toString(), userId,
					cmbDiscountAmount);

			Thread.sleep(5000);
			// 支付后金额
			Map act = new HashMap();
			act.put("userId", userId);
			// 定金充值流水
			act.put("originalNo", String.valueOf(thirdTradingId));

			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			BigDecimal accountEntryPrice = actinfos.stream()
					.map(a -> a.getAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			// 支付网关充值流水
			Logger.verifyEquals(totalPrice.subtract(blanceAmout).setScale(2),
					accountEntryPrice, "验证账户资金订单充值流水金额");

			// 定金支付流水
			act.put("originalNo", String.valueOf(tradingId));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);
			accountEntryPrice = actinfos.stream().map(a -> a.getAmount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);
			// 定金支付流水
			Logger.verifyEquals(totalPrice.setScale(2),
					accountEntryPrice.divide(new BigDecimal(-1), 2, 4),
					"验证账户资金订单支付流水金额");

			Logger.debug("cmbDiscountAmount:" + cmbDiscountAmount);

			List<YmtOrders> orderList = new YmtOrdersWapper()
					.selectbyMainOrder(tradingId);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("Form",
					orderpayrequestcall.getData().get("resultType"), "验证Code");
			// 验证支付网关返回报文
			verifyCmb(Integer.valueOf(thirdTradingId), orderList, totalPrice,
					totalPrice.subtract(blanceAmout), new BigDecimal(
							cmbDiscountAmount));
			// 验证支付网关返回报文
			verifyPackageInfo(orders.get(0).getOrderId());

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_038() {
		Logger.start(true, "使用支付宝支付,可选为支付方式(70:宝付)，验证宝付支付接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder7();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			orderpayrequestbean.setTerminalSource(TerminalSourceEnum.Android);
			orderpayrequestbean.setOptionalPayTypes(Arrays.asList(70));
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("BaofooToken", orderpayrequestcall.getData()
					.get("resultType"), "验证resultType");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_039() {
		Logger.start(true, "使用支付宝支付,可选为支付方式为空，验证接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder4();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			orderpayrequestbean.setTerminalSource(TerminalSourceEnum.Android);
			//orderpayrequestbean.setOptionalPayTypes(Arrays.asList(70));
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");

			Logger.verifyEquals("JSON",
					orderpayrequestcall.getData().get("resultType"),
					"验证resultType");
			// 验证支付网关返回报文
			verifyAlipayApp(orderId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_040() {
		Logger.start(true, "使用支付宝支付,可选为支付方式为不存在的类型，验证接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder4();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			orderpayrequestbean.setTerminalSource(TerminalSourceEnum.Android);
			orderpayrequestbean.setOptionalPayTypes(Arrays.asList(71));
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");

			Logger.verifyEquals("JSON",
					orderpayrequestcall.getData().get("resultType"),
					"验证resultType");
			// 验证支付网关返回报文
			verifyAlipayApp(orderId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	public void Tc_OrderPayRequest_041() {
		Logger.start(true, "订单为贝海保税,使用支付宝支付,可选为支付方式为宝付-70，验证接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService
					.placeOrderBylogisticsType(LogisticsTypeEnum.XloboBondedDelivery);

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			orderpayrequestbean.setTerminalSource(TerminalSourceEnum.Android);
			orderpayrequestbean.setOptionalPayTypes(Arrays.asList(70));
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");

			Logger.verifyEquals("JSON",
					orderpayrequestcall.getData().get("resultType"),
					"验证resultType");
			// 验证支付网关返回报文
			verifyAlipayApp(orderId);

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_042() {
		Logger.start(true, "使用微信支付,可选为支付方式为宝付(70)，验证接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService
					.placeOrderBylogisticsType(LogisticsTypeEnum.XloboBondedDelivery);

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("15");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			orderpayrequestbean.setTerminalSource(TerminalSourceEnum.Android);
			orderpayrequestbean.setOptionalPayTypes(Arrays.asList(70));
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");

			Logger.verifyEquals("JSON",
					orderpayrequestcall.getData().get("resultType"),
					"验证resultType");
			// 验证支付网关返回报文
			verifyWeixin();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_043() {
		Logger.start(true, "使用宝付支付,模拟网关支付通知回调,验证宝付支付接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder5();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			BigDecimal totalPrice = placeOrderResp.getPayAmount();

			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			orderpayrequestbean.setTerminalSource(TerminalSourceEnum.Android);
			orderpayrequestbean.setOptionalPayTypes(Arrays.asList(70));
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");

			Logger.comment("第三方支付回调");

			PaymentProxyCallService.notifyCall("70", thirdTradingId, totalPrice
					.subtract(BigDecimal.ZERO).toString(), userId);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("BaofooToken", orderpayrequestcall.getData()
					.get("resultType"), "验证resultType");

			DefaultWapper database = new DefaultWapper();

			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 2);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);

			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");

			Map act = new HashMap();
			List<YmtAccountEntry> actinfos = new ArrayList<YmtAccountEntry>();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			Logger.verifyEquals(totalPrice.setScale(2), actinfos.get(0)
					.getAmount().divide(new BigDecimal(-1), 2, 4),
					"验证账户资金流水用户支付金额");

			act.remove("bizno");
			act.put("originalNo", String.valueOf(thirdTradingId));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			Logger.verifyEquals(totalPrice.subtract(BigDecimal.ZERO)
					.setScale(2), actinfos.get(0).getAmount(),
					"验证账户资金流水第三方支付充值金额");

		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_044() {

		Logger.start(true, "使用宝付,余额混合支付,模拟网关支付通知回调,验证宝付支付接口返回报文");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder5();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			BigDecimal totalPrice = placeOrderResp.getPayAmount();

			BigDecimal blance = new BigDecimal(new Random().nextInt(50));

			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(blance);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			orderpayrequestbean.setTerminalSource(TerminalSourceEnum.Android);
			orderpayrequestbean.setOptionalPayTypes(Arrays.asList(70));
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");

			Logger.comment("第三方支付回调");

			PaymentProxyCallService.notifyCall("70", thirdTradingId, totalPrice
					.subtract(blance).toString(), userId);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("BaofooToken", orderpayrequestcall.getData()
					.get("resultType"), "验证resultType");

			DefaultWapper database = new DefaultWapper();

			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 2);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);

			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");

			Map act = new HashMap();
			List<YmtAccountEntry> actinfos = new ArrayList<YmtAccountEntry>();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			Logger.verifyEquals(totalPrice.setScale(2), actinfos.get(0)
					.getAmount().divide(new BigDecimal(-1), 2, 4),
					"验证账户资金流水用户支付金额");

			act.remove("bizno");
			act.put("originalNo", String.valueOf(thirdTradingId));
			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			Logger.verifyEquals(totalPrice.subtract(blance).setScale(2),
					actinfos.get(0).getAmount(), "验证账户资金流水第三方支付充值金额");

		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_045() {

		Logger.start(true, "使用宝付支付,模拟网关支付通知回调前订单已取消,执行快速退款");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PlaceOrderService.placeOrder5();

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			BigDecimal totalPrice = placeOrderResp.getPayAmount();

			Logger.comment("前置数据准备结束");

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			// orderpayrequestbean.setUseAccountAmount(price1);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			orderpayrequestbean.setTerminalSource(TerminalSourceEnum.Android);
			orderpayrequestbean.setOptionalPayTypes(Arrays.asList(70));
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");

			// 取消改笔交易下其中一个子订单
			new OrderCallService().cancelOrder(orderId, userId);

			Logger.comment("第三方支付回调");

			PaymentProxyCallService.notifyCall("70", thirdTradingId, totalPrice
					.subtract(BigDecimal.ZERO).toString(), userId);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Logger.verifyEquals("BaofooToken", orderpayrequestcall.getData()
					.get("resultType"), "验证resultType");

			DefaultWapper database = new DefaultWapper();

			Map act = new HashMap();
			List<YmtAccountEntry> actinfos = new ArrayList<YmtAccountEntry>();

			act.put("originalNo", String.valueOf(thirdTradingId));

			actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			Logger.verifyEquals(totalPrice.subtract(BigDecimal.ZERO)
					.setScale(2), actinfos.get(0).getAmount(),
					"验证账户资金流水第三方支付充值金额");

			Logger.verifyEquals(
					totalPrice.subtract(BigDecimal.ZERO)
							.divide(new BigDecimal(-1)).setScale(2), actinfos
							.get(1).getAmount(), "验证账户资金流水快速退款金额");

		} catch (Exception e) {
			Logger.fail(e);
		}

	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_046() {
		Logger.start(true, "订单收件人,收件人在年度额度身份证黑名单里,贝海保税商品支付后，直接取消订单");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			String name = "张蒙";
			PlaceOrderResp placeOrderResp = placeOrder2(name,
					LogisticsTypeEnum.XloboBondedDelivery, false);

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();// 支付金额
			Logger.comment("前置数据准备结束");

			DefaultWapper database = new DefaultWapper();
			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(price);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_APP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");

			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			Thread.sleep(1000);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Map act = new HashMap();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 18);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);
			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(tradingId, (Integer) database.selectOrder(m)
					.get(0).get("iTradingId"), "验证iTradingId");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");
			Logger.verifyEquals(price.setScale(2), actinfos.get(0).getAmount()
					.divide(new BigDecimal(-1), 2, 4), "验证账户金额");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_047() {
		Logger.start(true, "订单支付价格为0.01.通过余额支付成功");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderReq req = PlaceOrderService.getDefaultOrderReq();

			req.setYmatouCoupon(null);

			req.getOrderGroups().get(0).setSellerCoupon(null);

			OrderItemVo itemVo = req.getOrderGroups().get(0).getOrders().get(0)
					.getOrderItems().get(0);

			itemVo.setProductNum(1);
			itemVo.setOriginalPrice(new BigDecimal("0.01"));
			itemVo.setEarnestPrice(new BigDecimal("0.01"));
			itemVo.setProductPrice(new BigDecimal("0.01"));

			PlaceOrderResp placeOrderResp = PlaceOrderService
					.callPlaceOrderService(req);

			int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal price = placeOrderResp.getPayAmount();// 支付金额

			Logger.comment("前置数据准备结束");

			DefaultWapper database = new DefaultWapper();
			// 参数
			orderpayrequestbean.setCallBackUrl("www.baidu.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(price);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "1234567890";
			orderpayrequestbean.setTradingPwd(tradingPassword);

			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("");
			orderpayrequestbean.setPayType("10");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_APP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");
			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();
			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");
			Map act = new HashMap();
			act.put("bizno", String.valueOf(orderId));
			act.put("userId", userId);
			List<YmtAccountEntry> actinfos = new AccountDefaultWapper()
					.selectAccountEntryByBizNo(act);

			HashMap m = new HashMap();
			m.put("OrderId", orderId);
			m.put("TradingStatus", 2);
			m.put("TraddingId", orderId);
			m.put("ReceiveUserId", sellerId);
			Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
			Logger.verifyEquals(tradingId, (Integer) database.selectOrder(m)
					.get(0).get("iTradingId"), "验证iTradingId");
			Logger.verifyEquals(1, database.selectTradingStatus(m).size(),
					"验证交易状态表");
			Logger.verifyEquals(price.setScale(2), actinfos.get(0).getAmount()
					.divide(new BigDecimal(-1), 2, 4), "验证账户金额");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_048() {
		Logger.start(true, "使用预付卡的订单,使用余额支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PrepaidCardService.placeOrder(true);

			List<Order> orders = placeOrderResp.getOrderList();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal totalNeedPayAmout = placeOrderResp.getPayAmount();// 支付金额

			Logger.comment("前置数据准备结束");

			// 获取用户需要支付的金额
			BigDecimal totalPrice = new OrderCallService()
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);

			BigDecimal blanceAmout = new BigDecimal(20);

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(totalPrice);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");

			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");

			List<YmtOrders> orderList = new YmtOrdersWapper()
					.selectbyMainOrder(tradingId);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");

			Logger.verifyEquals("null", orderpayrequestcall.getData()
					.getString("thirdPartyAmount"), "验证thirdPartyAmount");

			orderList.forEach(order -> {

				// ymtOrderState 表
					List<Map> ymtOrderState = new DefaultWapper()
							.selectOrderStateByOderId(order.getIorderid());

					Logger.verifyEquals(2, order.getItradingstatus(),
							"订单状态为2 已付款");

					DataUtil.verifyDateEquals(
							order.getFpayableamount().add(
									order.getfPrepaidAmount()), ymtOrderState
									.get(0).get("fPaidAmountOfCash"),
							"校验fPaidAmountOfCash");

				});

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_OrderPayRequest_049() {
		Logger.start(true, "使用预付卡的订单,使用余额+第三方组合支付");
		try {
			// 创建订单
			Logger.comment("前置数据准备");

			PlaceOrderResp placeOrderResp = PrepaidCardService.placeOrder(true);

			List<Order> orders = placeOrderResp.getOrderList();
			int sellerId = placeOrderResp.getOrderList().get(0).getSellerId();
			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();

			BigDecimal totalNeedPayAmout = placeOrderResp.getPayAmount();// 支付金额

			Logger.comment("前置数据准备结束");

			// 获取用户需要支付的金额
			BigDecimal totalPrice = new OrderCallService()
					.getNeedPrePayAmountOfCashBymainOrderId(tradingId);

			BigDecimal blanceAmout = new BigDecimal(20);

			// 参数
			orderpayrequestbean.setCallBackUrl("www.ymtautotest.com");
			orderpayrequestbean.setUserId(userId);
			orderpayrequestbean.setUseAccountAmount(blanceAmout);
			orderpayrequestbean.setTradingId(tradingId);
			String tradingPassword = "abc123";
			orderpayrequestbean.setTradingPwd(tradingPassword);
			orderpayrequestbean.setUserIp("127.0.0.10");
			orderpayrequestbean.setBankId("123");
			orderpayrequestbean.setPayType("13");
			orderpayrequestbean.setUsePlatform(PlatformEnum.SHANGOU_WAP
					.getValue());
			orderpayrequestbean.setParamExt("");
			orderpayrequestbean.setMemo("备注");

			// 发送请求
			orderpayrequestcall.setData(orderpayrequestbean);
			orderpayrequestcall.callService();

			String thirdTradingId = orderpayrequestcall.getData().getString(
					"tradingId");

			new OrderCallService().orderPayCallBack(thirdTradingId);

			Thread.sleep(2000);

			List<YmtOrders> orderList = new YmtOrdersWapper()
					.selectbyMainOrder(tradingId);

			Logger.verifyEquals(ECode.SUCCESS, orderpayrequestcall.getCode(),
					"验证Code");

			DataUtil.verifyDecimalEquals(totalPrice.subtract(blanceAmout)
					.toString(), new BigDecimal(orderpayrequestcall.getData()
					.getString("thirdPartyAmount")), "验证thirdPartyAmount");

			orderList.forEach(order -> {

				// ymtOrderState 表
					List<Map> ymtOrderState = new DefaultWapper()
							.selectOrderStateByOderId(order.getIorderid());

					Logger.verifyEquals(2, order.getItradingstatus(),
							"订单状态为2 已付款");

					DataUtil.verifyDateEquals(
							order.getFpayableamount().add(
									order.getfPrepaidAmount()), ymtOrderState
									.get(0).get("fPaidAmountOfCash"),
							"校验fPaidAmountOfCash");

				});

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	/**
	 * 校验招行平台补贴金额分摊逻辑
	 * 
	 * @param tradingId
	 *            第三方支付交易号
	 * @param needPayAmount
	 *            该笔交易总需要支付金额（包含多个订单）
	 */
	private void verifyCmb(int tradingId, List<YmtOrders> orderList,
			BigDecimal needPayAmount, BigDecimal thirdPayAmount,
			BigDecimal cmbDiscountAmount) {
		DefaultWapper database = new DefaultWapper();
		try {
			BigDecimal cmbTemp = BigDecimal.ZERO;
			BigDecimal dtemp = BigDecimal.ZERO;
			// 该笔交易总商品成交价格
			BigDecimal totalPrice = orderList.stream()
					.map(o -> o.getFtotalprice())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			// 该笔交易总商品成交价格
			BigDecimal totalPayableamount = orderList.stream()
					.map(o -> o.getFpayableamount())
					.reduce(BigDecimal.ZERO, BigDecimal::add);

			//计算分摊到订单上的招行补贴折扣
			BigDecimal orderWeights[] = new BigDecimal[orderList.size()];

			for (int i = 0; i < orderList.size(); i++) {

				orderWeights[i] = new OrderCallService()
						.getNeedPrePayAmountOfCash(orderList.get(i)
								.getIorderid());
			}

			BigDecimal orderDiscountResult[] = Ts_PlaceOrder
					.apportionByWeights(cmbDiscountAmount, orderWeights);

			BigDecimal orderThirdPartyResult[] = Ts_PlaceOrder
					.apportionByWeights(thirdPayAmount, orderWeights);

			for (int i = 0; i < orderList.size(); i++) {

				YmtOrders ymtOrder = orderList.get(i);

				int orderId = ymtOrder.getIorderid();

				// 订单商品明细
				List<YmtOrderInfo> ymtOrdersInfoList = new YmtOrderInfoWapper()
						.selectByOrderId(orderId);

				// 计算当前订单下所有商品总价
				BigDecimal orderProductPrice = ymtOrdersInfoList
						.stream()
						.map(o -> o.getFproductprice().multiply(
								new BigDecimal(o.getIamount())))
						.reduce(BigDecimal.ZERO, BigDecimal::add);

				// ymtOrderState 表
				List<Map> ymtOrderState = database
						.selectOrderStateByOderId(orderId);
				// ymt_orderpay 表
				List<Map> ymtOrderPay = database.selectOrderPay(orderId);

				// 查询当前订单需要支付的定金
				BigDecimal orderNeedPayAmount = new OrderCallService()
						.getNeedPrePayAmountOfCash(orderId);

				BigDecimal orderTotalPrice = ymtOrder.getFtotalprice();

				BigDecimal orderPayableAmount = ymtOrder.getFpayableamount();;

				Logger.comment("验证订单号:" + orderId);
				Logger.comment("验证ymt_order表");
				Logger.verifyEquals(2, ymtOrder.getItradingstatus(),
						"验证iTradingStatus");

				Logger.comment("验证ymt_orderState表");

				Logger.verifyEquals(1, ymtOrderState.size(),
						"验证ymt_orderState表");
				// 余额+第三方支付
				Logger.verifyEquals(
						orderNeedPayAmount.subtract(orderDiscountResult[i]),
						(BigDecimal) ymtOrderState.get(0).get(
								"fPaidAmountOfCash"), "验证fPaidAmountOfCash");

				Logger.verifyEquals(
						orderNeedPayAmount.subtract(orderThirdPartyResult[i]),
						(BigDecimal) ymtOrderState.get(0).get(
								"fPaidAmountOfYmtAccount"),
						"验证fPaidAmountOfYmtAccount");

				Logger.verifyEquals(
						orderThirdPartyResult[i]
								.subtract(orderDiscountResult[i]),
						(BigDecimal) ymtOrderState.get(0).get(
								"fPaidAmountOfThirdParty"),
						"验证fPaidAmountOfThirdParty");

				Logger.verifyEquals(
						orderDiscountResult[i].setScale(2),
						(BigDecimal) ymtOrderState.get(0).get(
								"fDiscountOfThirdParty"),
						"验证fDiscountOfThirdParty");
				Logger.comment("验证ymt_orderpay表");
				Logger.verifyEquals(tradingId, (Integer) ymtOrderPay.get(0)
						.get("iTradingId"), "验证iTradingId");
				Logger.verifyEquals(2,
						(Integer) ymtOrderPay.get(0).get("iPayType"),
						"验证iPayType");
				Logger.verifyEquals(orderNeedPayAmount,
						(BigDecimal) ymtOrderPay.get(0).get("fAmount"),
						"验证fAmount");
				Logger.verifyEquals(0,
						(Integer) ymtOrderPay.get(0).get("iStatus"),
						"验证iStatus");
				Logger.verifyEquals("支付成功_第三方回调", (String) ymtOrderPay.get(0)
						.get("sMemo"), "验证sMemo");
				Logger.verifyEquals(0,
						(Integer) ymtOrderPay.get(0).get("iAccountingNum"),
						"验证iAccountingNum");
				Logger.verifyEquals("操作成功！",
						(String) ymtOrderPay.get(0).get("sAccountingMessage"),
						"验证sAccountingMessage");

				Logger.comment("验证Ymt_OrderInfo表");

				//计算从订单上分摊到商品
				BigDecimal productWeights[] = new BigDecimal[ymtOrdersInfoList
						.size()];

				for (int j = 0; j < ymtOrdersInfoList.size(); j++) {

					productWeights[j] = ymtOrdersInfoList
							.get(j)
							.getFproductprice()
							.multiply(
									new BigDecimal(ymtOrdersInfoList.get(j)
											.getIamount()));
				}

				BigDecimal proDiscountResult[] = Ts_PlaceOrder
						.apportionByWeights(orderDiscountResult[i],
								productWeights);

				for (int j = 0; j < ymtOrdersInfoList.size(); j++) {

					Logger.comment("验证第" + (j + 1) + "个商品招商银行补贴金额分摊");

					Logger.verifyEquals(
							proDiscountResult[j].setScale(2),
							ymtOrdersInfoList.get(j).getFthirdpartydiscount() == null
									? BigDecimal.ZERO.setScale(2)
									: ymtOrdersInfoList.get(j)
											.getFthirdpartydiscount(),
							"验证fThirdPartyDiscount");

				}

			}

			// ymt_tradinginfo 表
			List<Map> ymtTradinginfo = database
					.selectTradinginfoByTradingId(tradingId);
			Logger.comment("验证ymt_tradinginfo表");
			Logger.verifyEquals(thirdPayAmount.divide(new BigDecimal(1), 2, 4),
					(BigDecimal) ymtTradinginfo.get(0).get("fAmount"),
					"验证fAmount");
			Logger.verifyEquals(2,
					(Integer) ymtTradinginfo.get(0).get("iTradingStatus"),
					"验证iTradingStatus");
			Logger.verifyEquals(needPayAmount,
					(BigDecimal) ymtTradinginfo.get(0).get("fPayableAmount"),
					"验证fPayableAmount");

			Logger.verifyEquals(
					cmbDiscountAmount.setScale(2),
					(BigDecimal) ymtTradinginfo.get(0).get(
							"fDiscountOfThirdParty"), "验证fDiscountOfThirdParty");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	// 校验全余额支付
	private void verifyDb(int orderId) {
		// 交易号
		long tradingId = orderpayrequestbean.getTradingId();
		// 用户id
		int userId = orderpayrequestbean.getUserId();
		// 用户支付的余额
		BigDecimal payAmount = orderpayrequestbean.getUseAccountAmount()
				.setScale(2);

		DefaultWapper database = new DefaultWapper();
		// 订单主表
		List<Map> ymtOrders = database.selectOrderByOderId(orderId);
		// 订单商品明细
		List<Map> ymtOrdersInfoList = database.selectOrderInfoByOderId(orderId);
		// ymt_tradinginfo 表
		List<Map> ymtTradinginfo = database
				.selectTradinginfoByTradingId((int) tradingId);
		// ymtOrderState 表
		List<Map> ymtOrderState = database.selectOrderStateByOderId(orderId);
		// ymt_orderpay 表
		List<Map> ymtOrderPay = database.selectOrderPay(orderId);
		// 订单定金金额
		BigDecimal orderPrice = (BigDecimal) ymtOrders.get(0)
				.get("fOrderPrice");
		// 运费
		BigDecimal freight = (BigDecimal) ymtOrders.get(0).get("fFreight");
		// 优惠券金额
		BigDecimal couponValue = (BigDecimal) ymtOrders.get(0).get(
				"CouponValue");
		// 商家用户优惠券金额
		BigDecimal sellerCouponValue = (BigDecimal) ymtOrders.get(0).get(
				"fSellerCouponAmount");
		// 平台用户优惠券金额
		BigDecimal ymtCouponValue = (BigDecimal) ymtOrders.get(0).get(
				"fYmtCouponAmount");

		// 订单应付金额
		BigDecimal needPayAmount = orderPrice.add(freight)
				.subtract(sellerCouponValue).subtract(ymtCouponValue);
		Logger.comment("验证订单号:" + orderId);
		Logger.comment("验证ymt_order表");
		Logger.verifyEquals(2,
				(Integer) ymtOrders.get(0).get("iTradingStatus"),
				"验证iTradingStatus");

		Logger.comment("验证ymt_orderState表");
		Logger.verifyEquals(1, ymtOrderState.size(), "验证ymt_orderState表");
		/*		Logger.verifyEquals(couponValue,
						(BigDecimal) ymtOrderState.get(0).get("fPaidAmountOfCoupon"),
						"验证fPaidAmountOfCoupon");*/
		Logger.verifyEquals(needPayAmount, (BigDecimal) ymtOrderState.get(0)
				.get("fPaidAmountOfCash"), "验证fPaidAmountOfCash");
		Logger.verifyEquals(sellerCouponValue, (BigDecimal) ymtOrderState
				.get(0).get("fPaidAmountOfSellerCoupon"),
				"验证fPaidAmountOfSellerCoupon");
		Logger.verifyEquals(ymtCouponValue, (BigDecimal) ymtOrderState.get(0)
				.get("fPaidAmountOfYmtCoupon"), "验证fPaidAmountOfYmtCoupon");
		Logger.verifyEquals(needPayAmount, (BigDecimal) ymtOrderState.get(0)
				.get("fPaidAmountOfYmtAccount"), "验证fPaidAmountOfYmtAccount");

		Logger.comment("验证ymt_orderpay表");
		Logger.verifyEquals(tradingId,
				(Integer) ymtOrderPay.get(0).get("iTradingId"), "验证iTradingId");
		Logger.verifyEquals(1, (Integer) ymtOrderPay.get(0).get("iPayType"),
				"验证iPayType");
		Logger.verifyEquals(needPayAmount,
				(BigDecimal) ymtOrderPay.get(0).get("fAmount"), "验证fAmount");
		Logger.verifyEquals(0, (Integer) ymtOrderPay.get(0).get("iStatus"),
				"验证iStatus");
		Logger.verifyEquals("支付成功_余额",
				(String) ymtOrderPay.get(0).get("sMemo"), "验证sMemo");
		Logger.verifyEquals(0,
				(Integer) ymtOrderPay.get(0).get("iAccountingNum"),
				"验证iAccountingNum");
		Logger.verifyEquals("操作成功！",
				(String) ymtOrderPay.get(0).get("sAccountingMessage"),
				"验证sAccountingMessage");
	}

	/**
	 * 校验Html Form返回 支付宝PC支付
	 * 
	 * @param orderId
	 * @throws Exception
	 */
	private void verifyHtmlResult(int orderId, BigDecimal needThirdPayAmount)
			throws Exception {
		Logger.comment("验证支付宝PC Result");
		Map m = new HashMap<String, String>();
		// 订单主表
		List<Map> ymtOrders = new DefaultWapper().selectOrderByOderId(orderId);
		BigDecimal totalFee = needThirdPayAmount;
		String productName = (String) ymtOrders.get(0).get("sBuyerLoginId")
				+ "的订单";
		// 返回报文result
		String result = orderpayrequestcall.getData().getString("result");
		List<String> namelist = TestDataManager.getRegexList(result,
				"(?<=name=\").*?(?=\")");
		List<String> valuelist = TestDataManager.getRegexList(result,
				"(?<=value=\").*?(?=\")");
		if (valuelist.size() == namelist.size()) {
			for (int i = 0; i < namelist.size(); i++) {
				m.put(namelist.get(i), valuelist.get(i));
			}
		} else {
			throw new Exception("verifyResult失败，结果集name value 不匹配");
		}
		PPBussinessOrder ppb = new PaymentDefaultWapper()
				.selectPPBussinessorderByOrderId(
						orderpayrequestcall.getData().getString("tradingId"))
				.get(0);

		HashMap mext = (HashMap) FormatUtil.GSONToObject(ppb.getExt(),
				HashMap.class);
		int isHangzhou = Double.valueOf(mext.get("IsHangZhou").toString())
				.intValue();

		String businessoid = ppb.getBussinessOrderId();
		PPPayment ppm = new PaymentDefaultWapper()
				.selectPPPaymentByBussinessOrderId(businessoid).get(0);
		String trandno = ppm.getPaymentId();

		Logger.verifyEquals("MD5", m.get("sign_type"), "验证sign_type");
		if (EnvSetup.getEnv().equals("sit1")) {
			Logger.verifyEquals(
					"http://" + "sit" + ".payment.ymatou.com:8380/notify/"
							+ orderpayrequestbean.getPayType(),
					m.get("notify_url"), "验证notify_url");
			Logger.verifyEquals("http://" + "sit"
					+ ".payment.ymatou.com:8380/callback/"
					+ orderpayrequestbean.getPayType(), m.get("return_url"),
					"验证return_url");
		} else if (EnvSetup.getEnv().equals("uat")) {
			Logger.verifyEquals(
					"http://" + "uat" + ".payment.ymatou.com:8480/notify/"
							+ orderpayrequestbean.getPayType(),
					m.get("notify_url"), "验证notify_url");
			Logger.verifyEquals("http://" + "uat"
					+ ".payment.ymatou.com:8480/callback/"
					+ orderpayrequestbean.getPayType(), m.get("return_url"),
					"验证return_url");
		}
		Logger.verifyEquals(trandno, m.get("out_trade_no"), "验证out_trade_no");

		// sign算法未知
		Logger.verifyNotNull(m.get("sign"), "验证sign非空");
		Logger.verifyEquals("utf-8", m.get("_input_charset"),
				"验证_input_charset");
		Logger.verifyEquals(orderpayrequestbean.getUserIp(),
				m.get("exter_invoke_ip"), "验证exter_invoke_ip");
		Logger.verifyEquals(
				true,
				TestDataManager.equalsBigDecimal(
						new BigDecimal(m.get("total_fee").toString()),
						totalFee.toString()),
				"验证total_fee:" + m.get("total_fee"));
		if (isHangzhou == 1) {
			Logger.comment("验证杭保信息");
			Logger.verifyEquals(
					"{&quot;needBuyerRealnamed&quot;:&quot;T&quot;}",
					m.get("buyer_info"), "验证buyer_info买家信息");
			Logger.verifyEquals("alipay.acquire.page.createandpay",
					m.get("service"), "验证service统一下单并支付");
			Logger.verifyEquals("FAST_INSTANT_TRADE_PAY",
					m.get("product_code"), "验证product_code订单业务类型");
		} else {
			Logger.comment("验证非杭保信息");
			Logger.verifyEquals(orderpayrequestbean.getBankId(),
					m.get("defaultbank"), "验证defaultbank默认银行");
			Logger.verifyEquals("create_direct_pay_by_user", m.get("service"),
					"验证service统一下单并支付");
			Logger.verifyEquals(ppb.getThirdPartyUserId() == null ? "N" : "Y",
					m.get("default_login"), "验证default_login默认登录");
		}
		// 固定
		Logger.verifyEquals(PayGateWayCallService.Alipay_MERID, m.get("partner"),
				"验证partner合作者身份ID");
		Logger.verifyNotNull(m.get("anti_phishing_key"),
				"验证anti_phishing_key防钓鱼时间戳");
		Logger.verifyEquals(PayGateWayCallService.Alipay_EMAIL, m.get("seller_email"),
				"验证seller_email买家支付宝账号");
		Logger.verifyEquals("1", m.get("payment_type"),
				"验证payment_type 1（商品购买）");
	}
	/**
	 * 校验Html Form返回 招行 CMB
	 * 
	 * @param orderId
	 * @throws Exception
	 */
	private void verifyCMBHtmlResult(Integer orderId,
			BigDecimal needThirdPayAmount) throws Exception {
		Logger.comment("验证招商银行CMB FORM Result");
		Map m = new HashMap<String, String>();
		// 订单主表
		List<Map> ymtOrders = new DefaultWapper().selectOrderByOderId(orderId);
		BigDecimal totalFee = needThirdPayAmount;
		String productName = (String) ymtOrders.get(0).get("sBuyerLoginId")
				+ "的订单";
		// 返回报文result
		String result = orderpayrequestcall.getData().getString("result");
		List<String> nameList = TestDataManager.getRegexList(result,
				"(?<=name=\").+?(?=\")");
		List<String> valuelist = TestDataManager.getRegexList(result,
				"(?<=value=\').+?(?=\' />)");

		String name = nameList.get(0);
		String value = valuelist.get(0);

		JSONObject valueJSON = new JSONObject(value);

		String charset = valueJSON.getString("charset");
		String reqData = valueJSON.getString("reqData");
		String sign = valueJSON.getString("sign");
		String signType = valueJSON.getString("signType");

		HashMap reqDataMap = (HashMap) FormatUtil.GSONToObject(reqData,
				HashMap.class);

		PPBussinessOrder ppb = new PaymentDefaultWapper()
				.selectPPBussinessorderByOrderId(
						orderpayrequestcall.getData().getString("tradingId"))
				.get(0);

		HashMap mext = (HashMap) FormatUtil.GSONToObject(ppb.getExt(),
				HashMap.class);

		String businessoid = ppb.getBussinessOrderId();
		PPPayment ppm = new PaymentDefaultWapper()
				.selectPPPaymentByBussinessOrderId(businessoid).get(0);
		String trandno = ppm.getPaymentId();

		Logger.verifyEquals("SHA-256", signType, "验证signType");
		/*
		 * if (EnvSetup.getEnv().equals("sit1")) { Logger.verifyEquals(
		 * "http://116.228.41.4:8081/cmbPayNotify" ,
		 * reqDataMap.get("payNoticeUrl"), "验证payNoticeUrl");
		 * Logger.verifyEquals( "http://116.228.41.4:8081/cmbSignNotify" ,
		 * reqDataMap.get("signNoticeUrl"), "验证signNoticeUrl"); } else if
		 * (EnvSetup.getEnv().equals("uat")) { Logger.verifyEquals(
		 * "http://116.228.41.4:8081/cmbPayNotify" ,
		 * reqDataMap.get("payNoticeUrl"), "验证payNoticeUrl");
		 * Logger.verifyEquals( "http://116.228.41.4:8081/cmbSignNotify" ,
		 * reqDataMap.get("signNoticeUrl"), "验证signNoticeUrl"); }
		 */
		Logger.verifyEquals(trandno, reqDataMap.get("orderNo"), "验证orderNo");

		// sign算法未知
		Logger.verifyNotNull(sign, "验证sign非空");
		Logger.verifyEquals(true, TestDataManager.equalsBigDecimal(
				new BigDecimal(reqDataMap.get("amount").toString()),
				totalFee.toString()), "验证total_fee:" + reqDataMap.get("amount"));

	}

	/**
	 * 校验组合商品落地数据
	 */
	private void verifyPackageInfo(int orderId) {

		try {

			Thread.sleep(5000);

			DefaultWapper database = new DefaultWapper();

			// 订单商品明细
			List<Map> ymtOrdersInfoList = database
					.selectOrderInfoByOderId(orderId);

			List<Map> ymtOrderSub = ymtOrdersInfoList.stream()
					.filter(item -> (Boolean) item.get("bSubProduct"))
					.collect(Collectors.toList());

			if (!CollectionUtils.isEmpty(ymtOrderSub)) {

				for (Map m : ymtOrderSub) {

					String sCatalogId = (String) m.get("sCatalogId");

					BigDecimal fProductPrice = (BigDecimal) m
							.get("fProductPrice");

					int iAmount = (Integer) m.get("iAmount");

					BigDecimal fFreight = (BigDecimal) m.get("fFreight");

					BigDecimal fSellerCouponAmount = (BigDecimal) m
							.get("fSellerCouponAmount");

					BigDecimal fYmtCouponAmount = (BigDecimal) m
							.get("fYmtCouponAmount");

					BigDecimal fThirdPartyDiscount = (BigDecimal) m
							.get("fThirdPartyDiscount");

					Logger.comment(String.format("校验sCatalogId：%s 的组合商品",
							sCatalogId));

					List<OrderInfoSubPo> OrderInfoSubPoList = database
							.getOrderInfoSub(orderId, sCatalogId);

					BigDecimal[] weight = new BigDecimal[OrderInfoSubPoList
							.size()];

					for (int j = 0; j < OrderInfoSubPoList.size(); j++) {

						OrderInfoSubPo orderInfoSubPo = OrderInfoSubPoList
								.get(j);

						weight[j] = orderInfoSubPo.getOriginalPrice().multiply(
								new BigDecimal(orderInfoSubPo.getNum()));
					}

					BigDecimal price[] = Ts_PlaceOrder.apportionByWeights2(
							fProductPrice.multiply(new BigDecimal(iAmount)),
							weight);

					BigDecimal freight[] = Ts_PlaceOrder.apportionByWeights2(
							fFreight, weight);

					BigDecimal sellerCoupon[] = Ts_PlaceOrder
							.apportionByWeights2(fSellerCouponAmount, weight);

					BigDecimal ymtCoupon[] = Ts_PlaceOrder.apportionByWeights2(
							fYmtCouponAmount, weight);

					BigDecimal thirdPartyDiscount[] = Ts_PlaceOrder
							.apportionByWeights2(fThirdPartyDiscount, weight);

					int k = 0;

					for (OrderInfoSubPo orderInfoSubPo : OrderInfoSubPoList) {

						Logger.comment("校验 Ymt_OrderInfoSub 表 ");

						Logger.comment("校验 SubOrderInfoId :"
								+ orderInfoSubPo.getSubOrderInfoId());

						DataUtil.verifyDecimalEquals(price[k],
								orderInfoSubPo.getPrice(), "校验Price");

						DataUtil.verifyDecimalEquals(freight[k],
								orderInfoSubPo.getFreight(), "校验Freight");

						DataUtil.verifyDecimalEquals(ymtCoupon[k],
								orderInfoSubPo.getYmtCoupon(), "校验YmtCoupon");
						DataUtil.verifyDecimalEquals(sellerCoupon[k],
								orderInfoSubPo.getSellerCoupon(),
								"校验SellerCoupon");
						DataUtil.verifyDecimalEquals(BigDecimal.ZERO,
								orderInfoSubPo.getPromotion(), "校验Promotion");

						DataUtil.verifyDecimalEquals(thirdPartyDiscount[k],
								orderInfoSubPo.getThirdPartyDiscount(),
								"校验ThirdPartyDiscount");

						k++;

					}

				}

			}

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
